package servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.MysqlDAO;

import beans.Filme;

/**
 * Servlet implementation class for Servlet: CadastrarFilme
 *
 */
 public class CadastrarFilme extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public CadastrarFilme() {
		super();
	}   	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Filme flm = new Filme();
		System.out.println("");
		flm.setNome(request.getParameter("nome"));
		flm.setCodigo_genero(Integer.parseInt(request.getParameter("generos")));
		flm.setData(flm.montaData(request.getParameter("mes"), request.getParameter("ano")));
		MysqlDAO msql = new MysqlDAO();
		msql.cadastarFilmes(flm);
		response.sendRedirect("filmeok.html");
		
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}   	  	    
}